package top.lingkang.acgv.controller;

import com.alibaba.fastjson.JSONObject;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.lingkang.acgv.acr.dto.ResponseResult;

/**
 * @author lingkang
 * @date 2021/7/30 23:45
 * @description
 */
@RestController
@RequestMapping("/auth")
public class UserController {
    @GetMapping("info")
    public Object info(Authentication authentication) {
        if (authentication == null) {
            return new ResponseResult<>().fail("禁止匿名访问！Prohibit anonymous access");
        }
        return new ResponseResult<>().success(JSONObject.toJSON(authentication.getPrincipal()));
    }
}
